﻿using System;
using System.IO;
using System.Reflection;

namespace Td.Additional.Runtime
{
    /// <summary>
    /// Application properties class
    /// </summary>
    public class Application
    {
        /// <summary>
        /// Gets the name.
        /// </summary>
        /// <value>The name.</value>
        public static String Name
        {
            get
            {
                return Path.GetFileNameWithoutExtension(
                    Assembly.GetEntryAssembly().Location);
            }
        }

        /// <summary>
        /// Gets the title.
        /// </summary>
        /// <value>The title.</value>
        public static String Title
        {
            get
            {
                Assembly assembly = Assembly.GetEntryAssembly();
                object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                return attributes.Length == 0 ? String.Empty : ((AssemblyTitleAttribute)attributes[0]).Title;
            }
        }

        /// <summary>
        /// Gets the manufacturer.
        /// </summary>
        /// <value>The manufacturer.</value>
        public static String Manufacturer
        {
            get
            {
                Assembly assembly = Assembly.GetEntryAssembly();
                object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
                return attributes.Length == 0 ? String.Empty : ((AssemblyCompanyAttribute)attributes[0]).Company;
            }
        }

        /// <summary>
        /// Gets the description.
        /// </summary>
        /// <value>The description.</value>
        public static String Description
        {
            get
            {
                Assembly assembly = Assembly.GetEntryAssembly();
                object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                return attributes.Length == 0 ? String.Empty : ((AssemblyDescriptionAttribute)attributes[0]).Description;
            }
        }
    }
}